package fdd.sys.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import fdd.sys.hbm.UsersManager;

@SuppressWarnings("serial")
public class Login extends ActionSupport {
	private String username;
	private String password;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		// return super.execute();
		if (getUsername().equals("whk") && getPassword().equals("whk")) {
			int i = 0;
			ActionContext.getContext().getSession().put("user", getUsername());
			Object count = ActionContext.getContext().getSession().get("count");
			if (null == count) {
				i += 1;
				System.out.println("i=0");
				ActionContext.getContext().getSession().put("count", i);
			} else {
				i = Integer.parseInt(count.toString());
				i += 1;
				ActionContext.getContext().getSession().put("count", i);
				System.out.println("i==" + i);
			}
			UsersManager um = new UsersManager();
			um.doSth();
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

}
